﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace UI.Desktop
{
    public partial class frmEditarBox : Form
    {
        public frmEditarBox()
        {
            InitializeComponent();
        }

        #region Boton Guardar

        private void btnGuardarBox_Click(object sender, EventArgs e)
        {
            Business.Entities.Box enBox = new Business.Entities.Box();

            string boxVieja = cbBox.Text.ToString();
            DataSet dsBox = new DataSet();
            dsBox = enBox.ObtenerDatosBox(boxVieja);

            dsBox.Tables["Box"].Rows[0][1] = txtNombre.Text;//actualizo el dataSet viejo con el nombre espec modificado.
            
            enBox.EditarBox(dsBox);
            MessageBox.Show("Box modificado con exito", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }

        #endregion

        #region Close 

        private void btnCerrar_Click(object sender, EventArgs e)
        {
            this.Close();

        }
        #endregion

        #region CBBOX
        
        private void cbBox_Click(object sender, EventArgs e)
        {
            Business.Entities.Box Box = new Business.Entities.Box();
            DataSet dsBox = new DataSet();
            dsBox = Box.ObtenerListaBoxs();
            ObtenerBox(dsBox);
        }

        private void ObtenerBox(DataSet dsBox)
        {
            cbBox.Text = "Seleccione su Box";
            cbBox.DataSource = dsBox.Tables["Box"];
            cbBox.DisplayMember = dsBox.Tables["Box"].Columns[1].Caption.ToString();
        }
        
        private void cbBox_TextChanged(object sender, EventArgs e)
        {
            txtNombre.Text = cbBox.Text.ToString();            
        }

        #endregion
    }
}
